<template>
  <div class="register">
    <el-form ref="registerForm" :model="registerForm" :rules="registerRules" class="register-form">
      <h3 class="title">面试登记</h3>
<!--      <el-form-item label="所属部门">-->
<!--        <el-select v-model="editForm.departmentId" placeholder="请选择">-->
<!--          <el-option-->
<!--            v-for="item in departments"-->
<!--            :label="item.name"-->
<!--            :value="item.id">-->
<!--            <span style="float: left">{{ item.name }}</span>-->
<!--            <span style="float: right; color: #8492a6; font-size: 13px">{{ item.sn }}</span>-->
<!--          </el-option>-->
<!--        </el-select>-->
<!--      </el-form-item>-->
      <el-form-item prop="classId">
        <el-select
          v-model="registerForm.classId"
          placeholder="请选择班级"
          clearable
          style="width: 240px"
        >
          <el-option
            v-for="dict in dict.type.sys_normal_disable"
            :key="dict.value"
            :label="dict.label"
            :value="dict.value"
          />
        </el-select>
      </el-form-item>
      <el-form-item prop="studentName">
        <el-input v-model="registerForm.studentName" type="text" auto-complete="off" placeholder="真实姓名">
        </el-input>
      </el-form-item>
      <el-form-item prop="interviewTime">
        <el-date-picker v-model="registerForm.interviewTime" format="yyyy-MM-dd" value-format="yyyy-MM-dd"
                        :style="{width: '100%'}" placeholder="请选择时间" clearable></el-date-picker>
      </el-form-item>
      <el-form-item prop="companyName">
        <el-input v-model="registerForm.companyName" type="text" auto-complete="off" placeholder="请输入公司名字">
        </el-input>
      </el-form-item>
      <el-form-item prop="hrName">
        <el-input v-model="registerForm.hrName" type="text" auto-complete="off" placeholder="请输入人事名字">
        </el-input>
      </el-form-item>
      <el-form-item prop="hrPhone">
        <el-input v-model="registerForm.hrPhone" type="text" auto-complete="off" placeholder="请输入人事电话">
        </el-input>
      </el-form-item>
      <el-form-item prop="interviewAddress">
        <el-input v-model="registerForm.interviewAddress" type="text" auto-complete="off" placeholder="请输入面试地址">
        </el-input>
      </el-form-item>
      <el-form-item prop="remark">
        <el-input v-model="registerForm.remark" type="textarea" placeholder="请输入备注"
                  :autosize="{minRows: 2, maxRows: 4}" :style="{width: '100%'}"></el-input>
      </el-form-item>

      <el-form-item style="width:100%;">
        <el-button
          :loading="loading"
          size="medium"
          type="primary"
          style="width:100%;"
          @click.native.prevent="handleRegister"
        >
          <span v-if="!loading">提交登记</span>
          <span v-else>登 记 中...</span>
        </el-button>
<!--        <div style="float: right;">-->
<!--          <router-link class="link-type" :to="'/login'">使用已有账户登录</router-link>-->
<!--        </div>-->
      </el-form-item>
    </el-form>
    <!--  底部  -->
    <div class="el-register-footer">
      <span>Copyright © 2018-2022 ruoyi.vip All Rights Reserved.</span>
    </div>
  </div>
</template>

<script>

export default {
  // name: "Register",
  data() {
    return {
      codeUrl: "",
      registerForm: {
        classId: "",
        studentName: "",
        interviewTime: "",
        companyName: "",
        hrName: "",
        hrPhone: "",
        interviewAddress: "",
        remark: ""
      },
      registerRules: {
        classId: [
          { required: true, trigger: "blur", message: "请选择班级" },
        ],
        studentName: [
          { required: true, trigger: "blur", message: "请输入你的真实名字" },
        ]
      },
      loading: false,
      captchaEnabled: true
    };
  },
  methods: {
    handleRegister() {
      this.$refs.registerForm.validate(valid => {
        if (valid) {
          this.loading = true;
          register(this.registerForm).then(res => {
            const username = this.registerForm.username;
            this.$alert("<font color='red'>恭喜你，您的账号 " + username + " 注册成功！</font>", '系统提示', {
              dangerouslyUseHTMLString: true,
              type: 'success'
            }).then(() => {
              this.$router.push("/login");
            }).catch(() => {});
          }).catch(() => {
            this.loading = false;
            if (this.captchaEnabled) {
              this.getCode();
            }
          })
        }
      });
    },
    getClasses() {

    }
  }
};
</script>

<style rel="stylesheet/scss" lang="scss">
.register {
  display: flex;
  justify-content: center;
  align-items: center;
  height: 100%;
  background-image: url("../assets/images/login-background.jpg");
  background-size: cover;
}
.title {
  margin: 0px auto 30px auto;
  text-align: center;
  color: #707070;
}

.register-form {
  border-radius: 6px;
  background: #ffffff;
  width: 400px;
  padding: 25px 25px 5px 25px;
  .el-input {
    height: 38px;
    input {
      height: 38px;
    }
  }
  .input-icon {
    height: 39px;
    width: 14px;
    margin-left: 2px;
  }
}
.register-tip {
  font-size: 13px;
  text-align: center;
  color: #bfbfbf;
}
.register-code {
  width: 33%;
  height: 38px;
  float: right;
  img {
    cursor: pointer;
    vertical-align: middle;
  }
}
.el-register-footer {
  height: 40px;
  line-height: 40px;
  position: fixed;
  bottom: 0;
  width: 100%;
  text-align: center;
  color: #fff;
  font-family: Arial;
  font-size: 12px;
  letter-spacing: 1px;
}
.register-code-img {
  height: 38px;
}
</style>
